package com.cloud_disk.mapper;

import com.cloud_disk.vo.ShareFileLinkInfo;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;
/**
 * @author 徐华星
 * 日期 2021/12/21
 */
@Mapper
public interface LinkInfoMapper {

    @Select("select * from t_sharelink where url = #{url}")
    ShareFileLinkInfo getLinkInfoByURL(@Param("url") String url);

    @Select("select * from t_sharelink where id = #{id}")
    ShareFileLinkInfo getLinkInfoById(@Param("id") Integer id);

    @Insert("insert into t_sharelink values(#{info.id},#{info.url},#{info.password},#{info.starttime},#{info.livetime}" +
            ",#{info.userid},#{info.fileid})")
    boolean addShareLink(@Param("info") ShareFileLinkInfo info);

    @Select("select * from t_sharelink where userid=#{userid}")
    List<ShareFileLinkInfo> getAllShareLinkByUserId(@Param("userid") Integer userid);

    @Update("update t_sharelink set starttime=#{starttime} livetime=#{livetime} where id=#{id}")
    void updateLinkInfoLivetimeByInfoid(@Param("id") Integer id,@Param("starttime") Date starttime,@Param("livetime") Date livetime);

    @Delete("delete from t_sharelink where id = #{id}")
    void deleteLinkInfoByInfoid(@Param("id") Integer id);


}
